dnl Set the protocol version to use

AC_DEFUN([AX_CONFIG_DOXYGEN],
[
    AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([$1])])
])

AC_DEFUN([AX_PROG_DOXYGEN],
[
    AC_ARG_ENABLE(
        [doc],
        AS_HELP_STRING([--enable-doc], [enable the documentation generation])
    )
    
    AS_IF(
        [test "x$enable_doc" = "xyes"],
        [
            AC_CHECK_PROGS([DOXYGEN], [doxygen])
            AS_IF(
                [test -z "$DOXYGEN"],
                [
                    AC_MSG_ERROR([cannot find doxygen, re-run configure with --disable-doc])
                ]
            )
        ]
    )
    
    AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
    
    dnl Default options
    AM_COND_IF([HAVE_DOXYGEN],
    [
        AC_CHECK_PROG([doxycfg_dot], [dot], [yes], [no])
        AC_CHECK_PROG([doxycfg_htags], [htags], [yes], [no])
        AC_PATH_PROG([doxycfg_perlpath], [perl], [])
        
        AX_DOXYGEN_HTML([yes])
        AX_DOXYGEN_XML([no])
        AX_DOXYGEN_LATEX([no])
        AX_DOXYGEN_MAN([no])
    ])
]
)

AC_DEFUN([AX_DOXYGEN_HTML], [AC_SUBST([doxycfg_html], [$1])])
AC_DEFUN([AX_DOXYGEN_XML], [AC_SUBST([doxycfg_xml], [$1])])
AC_DEFUN([AX_DOXYGEN_LATEX], [AC_SUBST([doxycfg_latex], [$1])])
AC_DEFUN([AX_DOXYGEN_MAN], [AC_SUBST([doxycfg_man], [$1])])
